<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:replace="layouts/master(title='学生列表')">   <!--layout文件路径-->
<th:block th:fragment="css">
    <!--如果没有内容，请保持-->
    <link rel="stylesheet" href="/plugins/bootstraptable/bootstrap-table.min.css">
    <style>
        /* 标题居中 */
        h1 {
            text-align: center;
        }
        /*调整间距*/
        .row{
            margin: 20px auto;
        }
        /* 修改新增学生按钮的颜色 */
        #addButton {
            background-color: #4ca6da;
            color: white;
        }
        /* 修改内联表单的颜色 */
        .form-inline .btn {
            background-color: lightskyblue;
            color: white;
        }
        /* 覆盖Bootstrap的表格样式 */
        .table.table-striped {
            margin:0 auto;
            border-collapse: collapse; /* 合并边框 */
            width: 90%; /* 调整表格宽度 */
            /*border: 1px solid #8d8b8b; !* 设置整个表格的边框 *!*/
        }
        .table.table-striped th,
        .table.table-striped td {
            padding: 8px; /* 添加内边距 */
            text-align: left; /* 文字居左 */
        }

    </style>
</th:block>

<div th:fragment="content">
    <h1>学生列表</h1>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <!-- Button trigger modal -->
                <button id="addButton" type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" onclick="preAdd();">
                    新增学生
                </button>
            </div>
            <div class="col-md-10">
                <!-- 查询表单 -->
                <div class="form-inline">
                    <input type="text" id="queryNo" class="form-control" placeholder="学号">
                    <input type="text" id="queryName" class="form-control" placeholder="姓名">
                    <select id="querySex" class="form-control">
                        <option value="">性别</option>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                    <select id="queryAgeRange" class="form-control">
                        <option value="">年龄段</option>
                        <option value="0-18">0-18</option>
                        <option value="19-30">19-30</option>
                        <option value="31-45">31-45</option>
                        <!-- 其他年龄段选项 -->
                    </select>
                    <select id="queryScoreRange" class="form-control">
                        <option value="">分数段</option>
                        <option value="0-59">0-59</option>
                        <option value="60-69">60-69</option>
                        <option value="70-79">70-79</option>
                        <option value="80-89">80-89</option>
                        <option value="90-99">90-99</option>
                        <option value="100-100">100</option>
                    </select>
                    <button class="btn btn-default" onclick="searchStudents()">查询</button>
                </div>
            </div>



        <!--表格-->
        <table class="table table-striped"  >
            <thead>
            <tr>
                <th>Id</th>
                <th>No</th>
                <th>Name</th>
<!--                <th>Password</th>-->
                <th>Sex</th>
                <th>Age</th>
                <th>Score</th>
                <th style="width:100px;">Operate</th>
            </tr>
            </thead>
            <tbody id="students">
            </tbody>
        </table>
            <!--表格-->
<!--            <table class="table table-striped" id="students" ></table>-->
    </div>
    <!--模态框-->
    <div class="modal fade" tabindex="-1" role="dialog" id="myModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">新增学生信息</h4>
                </div>
                <div class="modal-body">
                    <form id="formStudent">
                        <input hidden="hidden" id="id" name="id" />
                        <div class="form-group">
                            <label for="no">学号</label>
                            <input type="text" class="form-control" id="no" name="no" placeholder="No">
                        </div>
                        <div class="form-group">
                            <label for="name">姓名</label>
                            <input type="text" class="form-control" id="name" name="name" placeholder="Name">
                        </div>
                        <div class="form-group">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" name="password" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="sex">性别</label>
                            <select class="form-control" id="sex" name="sex">
                                <option value="1">男</option>
                                <option value="2">女</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="age">年龄</label>
                            <input type="text" class="form-control" id="age" name="age" placeholder="Age">
                        </div>
                        <div class="form-group">
                            <label for="score">分数</label>
                            <input type="text" class="form-control" id="score" name="score" placeholder="Score">
                        </div>
                    </form>
                    <!--表单结束-->
                </div>
                <div class="modal-footer">
<!--                   <button type="button" class="btn btn-primary" onclick="addStudent();">保存</button>-->
                    <!-- 模态框触发按钮 -->
                    <button id="saveButton" >保存</button>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

</div>
<div th:fragment="scripts">
    <!--如果没有内容，请保持-->
    <script src="/plugins/bootstraptable/bootstrap-table.min.js"></script>
    <script src="/plugins/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <!--        表单验证-->
    <script src="/plugins/jqvalidate/jquery.validate.min.js"></script>
    <script src="/plugins/jqvalidate/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="/pagejs/student/list2.js"></script>
</div>

</html>


